import { Component } from "cc"

export default class ExcelMgr extends Component {

  public static Instance: ExcelMgr = null

  private csvTables: any = {}

  onLoad() {
    if (ExcelMgr.Instance == null) {
      ExcelMgr.Instance = this
    } else {
      this.destroy()
      return
    }
  }

  public AddExcelTable(excelName: string, content: string, force?: boolean) {
    if (this.csvTables[excelName] && !force) return
    let tableData = {}
    let tableArr = []
    let opts = {
      header: true
    }
    CSV.parse(content, opts, function(row, keyName) {
      tableData[row[keyName]] = row
      tableArr.push(row)
    })

  }

  public SelectOne(excelName: string, key: string, val: any): any {

  }

  public SelectAll(): Array<any> {

  }

}